TEST
Section: Misc. Reference Manual Pages (1L)
Index
Return to Main Contents
NAME
test - check file types and compare values
SYNOPSIS
test
[expr]
DESCRIPTION
This manual page
documents the GNU version of
test.
test
returns a status of 0 (true) or 1 (false) depending on
the evaluation of
the conditional expression
expr.
Expressions may be unary or binary. Unary
expressions are often used to examine the status of a file. There
are string operators
and numeric comparison operators as well.
- -b file
-
True if file exists and is block special.
- -c file
-
True if file exists and is character special.
- -d file
-
True if file exists and is a directory.
- -e file
-
True if file exists
- -f file
-
True if file exists and is a regular file.
- -g file
-
True if file exists and is set-group-id.
- -k file
-
True if file has its ``sticky'' bit set.
- -L file
-
True if file exists and is a symbolic link.
- -p file
-
True if file exists and is a named pipe.
- -r file
-
True if file exists and is readable.
- -s file
-
True if file exists and has a size greater than zero.
- -S file
-
True if file exists and is a socket.
- -t [fd]
-
True if
fd
is opened on a terminal. If
fd
is omitted, it defaults to 1 (standard output).
- -u file
-
True if file exists and its set-user-id bit is set.
- -w file
-
True if file exists and is writable.
- -x file
-
True if file exists and is executable.
- -O file
-
True if file exists and is owned by the effective user id.
- -G file
-
True if file exists and is owned by the effective group id.
- file1 -nt file2
-
True if file1 is newer (according to
modification date) than file2.
- file1 -ot file2
-
True if file1 is older than file2.
- file1 -ef file
-
True if file1 and file2 have the same device and
inode numbers.
- -z string
-
True if the length of string is zero.
- -n string
-
- string
-
True if the length of
string
is non-zero.
- string1 = string2
-
True if the strings are equal.
- string1 != string2
-
True if the strings are not equal.
- ! expr
-
True if
expr
is false.
- expr1 -a expr2
-
True if both
expr1
and
expr2
are true.
- expr1 -o expr2
-
True if either
expr1
or
expr2
is true.
- arg1 OP arg2
-
OP
is one of
-eq,
-ne,
-lt,
-le,
-gt,
or
-ge.
These arithmetic binary operators return true if arg1
is equal, not-equal, less-than, less-than-or-equal,
greater-than, or greater-than-or-equal than arg2,
respectively.
arg1
and
arg2
may be positive integers, negative integers, or the special
expression -l string, which evaluates to the
length of
string.
Index
- NAME
-
- SYNOPSIS
-
- DESCRIPTION
-
This document was created by
man2html,
using the manual pages.
Time: 16:12:19 GMT, September 10, 2022